<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0" />
        <title>博客管理</title>
        <link rel="stylesheet" href="../Semantic-UI-CSS-master/semantic.min.css"/>
        <link rel="stylesheet" href="../css/me.css"/>
	</head>
	<body>
        <div class="bbb">
            <!-- 导航 -->
        <nav class="ui inverted attached segment m-padded-tb-min">
           <div class="ui container">
             <div class="ui inverted secondary stackable menu">
                 <h2 class="ui teal header item">管理后台</h2>
                 <a href="/admin/blogs" class="active item m-item m-mobile-hide"><i class="home icon"></i>博客</a>
                 <a href="/admin/types" class="item m-item m-mobile-hide"><i class="idea icon"></i> 分类</a>
                 <a href="/admin/tags" class="item m-item m-mobile-hide"><i class="tags icon"></i> 标签</a>
                 <a href="http://124.223.52.229:8802" class="item m-item m-mobile-hide"><i class="tags icon"></i> 文件上传</a>
                <div class="right item">
                    <div class="ui dropdown item">
                 <div class="text">
                     <img class="ui avatar image m-img-mid" src="../img/logo-icon-3.png" />
                    韦建韩
                 </div>
                 <i class="dropdown icon"></i>
                 <div class="menu">
                     <a href="/admin/loginOut" class="item">注销</a>
                     
                 </div>
                </div>
                </div>
             </div>  
           </div>
           <a href="#" class="ui menu toggel black icon button m-right-top m-mobile-show">
               <i class="sidebar icon"></i>
           </a>
        </nav>
        <div class="ui attached pointing menu">
            <div class="ui container">
                <a href="#" class="item">发布</a>
                <a href="#" class="active item">列表</a>
            </div>
            
        </div>
        <!-- 中间内容 -->
        <div class="m-padded-tb-lager m-container">
            <div class="ui container">
             <form action="#" method="post" class="ui segment form">
                 <input type="hidden" name="page"/>
             <div class="inline fields">
                 <div class="field">
                     <input type="text" name="title" placeholder="标题"/>
                 </div>
                 <div class="field">
                     <div class="ui selection dropdown">
                         <input type="hidden" name="typeId" />
                     <i class="dropdown icon"></i>
                     <div class="default text">分类</div>
                     <div class="menu">
                         <div class="item"></div>
                         <div th:each="type : ${types}"  class="item" th:data-value="${type.id}"  th:text="${type.name}">错误日志</div>
                     </div>
                     </div>
                 </div>
                 <div class="field">
                     <div class="ui checkbox">
                         <input type="checkbox" id="recommend" name = "recommend" />
                          <label for="recommend">推荐</label>
                     </div>
                 </div>
                 <div class="field">
                     <button type="button" id="search-btn" class="ui mini teal bais"><i class="search icon"></i>搜索 </button>
                 </div>
             </div>    
             </form>
                <div id="table-container">
            <table th:fragment="blogList" class="ui celled table">
                <thead>
                    <tr>
                        <th>序号</th>
                       <th>标题</th>
                       <th>类型</th>
                       <th>推荐</th>
                        <th>是否发布</th>
                       <th>更新实践</th>
                       <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr th:each="blog,iterStat : ${page.content}">
                        <td th:text="${iterStat.count}">1</td>
                        <td th:text="${blog.title}">可以练习的清单</td>
                        <td th:text="${blog.type.name}">认知升级</td>
                        <td th:text="${blog.recommend}? '是':'否'">是</td>
                        <td th:text="${blog.published}? '是（已发布）':'否（草稿）'"></td>
                        <td th:text="${blog.updateTime}">2021-03-05 17：01</td>
                        <td>
                         <a th:href="@{/admin/blogs/{id}/input(id=${blog.id})}" class="ui mini teal button">编辑</a>
                         <a th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" class="ui mini red button">删除</a>
                        </td>
                    </tr>
                </tbody>
                <tfoot>
                    <tr>
                        <th colspan="7">
                       <div class="ui pagination menu"  th:if="${page.totalPages}>1">
                           <a onclick="page(-1)" th:if="${page.number}>0"  class="item">上一页</a>
                           <a onclick="page(1)" th:unless="${page.last}"  class="item">下一页</a>
                       </div>     
                       <a href="/admin/blogs/input" class="ui mini right floated teal basic button">新增</a>
                        </th>
                    </tr>
                </tfoot>
            </table>
<!--                    消息提示-->
                    <div class="ui error message" th:unless="${#strings.isEmpty(message)}">
                        <i class="close icon"></i>
                        <div class="header">提示：</div>
                        <p th:text="${message}"></p>
                    </div>

                </div>
             </div>
              
            </div>
          
        <!-- 底部footer -->
        <footer class="ui inverted vertical segment m-padded-tb-massive">
            <div class="ui center aligned container">
                <div class="ui inverted divided stackable grid">
                 <div class="three wide column">
                     <img th:src="@{/img/logo-icon-3.png}" class="ui rounded image" alt="" style="width: 110px;"/>
                 </div>
                 <div class="three wide column">
                     <h4 class="ui inverted header">最新博客</h4>
                     <div class="ui inverted link list">
                         <a href="#" class="item">用户故事(User Story)</a>
                         <a href="#" class="item">用户故事(User Story)</a>
                         <a href="#" class="item">用户故事(User Story)</a>
                     </div>
                 </div>
                 <div class="three wide column"><h4 class="ui inverted header">联系我</h4>
                     <div class="ui inverted link list">
                         <a href="#" class="item">手机：17877887975</a>
                         <a href="#" class="item">QQ:2805319253</a>
                         <a href="#" class="item">邮箱：2805319253@qq.com</a>
                     </div></div>
                 
                 <div class="seven wide column">
                     <h4 class="ui inverted header">简介</h4>
                     <p>这是我的个人博客，我会与大家分享我的各种学习体会。</p>
                 </div>
                 
                </div>
                <div class="ui inverted section divider"></div>
               <p>韦建韩 就读于广西科技大学-启迪数字学院-软件工程专业</p>
                </div>
        </footer>
        </div>
        <script src="../Semantic-UI-CSS-master/jquery.js"></script>
        
        <script src="../Semantic-UI-CSS-master/semantic.min.js"></script>
        <script>
            $(".menu.toggle").click(function(){
                $(".m-item").toggleClass("m-mobile-hide");
            });
       //     消息关闭
            $('.message.close')
            .on('click',function () {
        $(this)
                .closest('message')
                .transition('fade');
            });

        var index = 0;
       $('.ui.dropdown').dropdown();
       function page(i) {
           if(i == -1)
            $('[name="page"]').val(--index);
           else $('[name="page"]').val(++index);


            loaddata();
       }
       $("#search-btn").click(function () {
    loaddata();
       })
       function loaddata() {
            $("#table-container").load("/admin/blogs/search",{
                title:$("[name = 'title']").val(),
                typeId:$("[name='typeId']").val(),

                recommend:$("[name='recommend']").prop('checked'),
                page:$("[name = 'page']").val()
            })
       }
        </script>
    </body>
</html>
